package com.clstu.regexp;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * 非贪婪匹配(默认是贪婪匹配)
 */
public class RegExp06 {
    public static void main(String[] args) {
        String content = "abccdddgd523679611111";
//        String regStr = "\\d+";//匹配1~n个数字,默认贪婪匹配
//        String regStr = "\\d+?";//匹配1~n个数字,非贪婪匹配,(在限定符后加上?)
        String regStr = "\\d*?";//匹配0~n个数字,非贪婪匹配,(在限定符后加上?)
        Pattern pattern = Pattern.compile(regStr);
        Matcher matcher = pattern.matcher(content);
        while (matcher.find()){
            System.out.println("找到:"+matcher.group(0));
        }
    }
}
